import pymysql
conn=None
cs =None
try:
    conn = pymysql.connect(host="211.103.136.244", port=7061,
                           user="student", password="iHRM_student_2021",
                           database="test_db", charset="utf8")
    cs = conn.cursor()
    res = cs.execute("insert into t_book(title, pub_date) values('好好学习吧', '2022-01-02');")
    print("影响的行数", res)
    conn.commit()

except Exception as e:
    print("打印错误结果",e)
    conn.rollback()
finally:
    cs.close()
    conn.close()







